import datetime

import jwt

from mypro.settings import SECRET_KEY

key = SECRET_KEY
class MyJWT():
    def getToken(self,user_id,user_name):
        user={
            "id":user_id,
            "username":user_name,
            'exp':datetime.datetime.now()+datetime.timedelta(hours=3)
        }
        return "Bearer "+jwt.encode(user,key,algorithm="HS256")

    def Checktoken(self,token):
        if token:
                return jwt.decode(token,key,algorithms=['HS256'])


myjwt=MyJWT()